<?php


namespace app\api\controller;


use think\Controller;
use think\Db;
use think\Request;

class WorldUser extends Controller
{
    public function register(){
       $request= Request::instance();
       $data = $request->param();
       //一条数据条件查询
//       Db::name("t_user")->where(["name" => $data["name","password"=>$data["password"]])->find();
//        查询全部数据
//        Db::name("t_user")->select();
        //往数据库中插入一条数据
        $insert_data =[
                "name" => $data["name"],
                "password" => $data["password"]
        ];
        //插入数据操作数据库
//
//        Db::name("t_user")->insert($insert_data);
        $userid = Db::name("t_user")->insertGetId($insert_data);
        $userinfo = Db::name("t_user")->where(["id"=>$userid])->find();
//        根据条件删除多条或一条数据
        Db::name("t_user")->where(["id"=>1])->delete();
        $result = [
          "code" =>200,
          "msg" =>"注册成功",
          "data" =>  $userinfo
        ];
       return $result;
    }
}